package com.exam.controller;

import com.exam.pojo.entity.QuestionJoin;
import com.exam.pojo.entity.TestJoin;
import com.exam.service.impl.TestJoinServicelmpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class TestJoinController {
    @Autowired
    TestJoinServicelmpl testJoinServicelmpl;
    //参加练习


    @RequestMapping("test-join.html")
    public String testJoinList(Model model){
        List<TestJoin> testJoinList = testJoinServicelmpl.findAll();
        List<TestJoin> allName = testJoinServicelmpl.findAllName();
        model.addAttribute("testJoinList",testJoinList);
        model.addAttribute("allName",allName);
        return "test-join";
    }
    //条件搜索
    @PostMapping("findTestJoin")
    public String selectTestJoin(Model model,String examName){
        List<TestJoin> allName = testJoinServicelmpl.findAllName();
        model.addAttribute("allName",allName);
        List<TestJoin> testJoinList = testJoinServicelmpl.findTestJoin(examName);
        model.addAttribute("testJoinList",testJoinList);
        return "test-join";
    }


}
